var selectNode;
var parentNode;
var rootNode;
var categorytree = new eiTreeModel('ZMCSF0');
var isAddedRefresh = false;
var treeObj;
//启动事件处理
$(document).ready(function() {
	efregion.show('ef_region_inqu');
	$("#_left").resizable({
		handles: "e",
		 iframeFix: true,  
		 stop: function( event, ui ) {
			 $("#_right").css("margin-left",  $("#_left").outerWidth());
		 }
	});
});
efform_onload = function ()
{
};
function configTree(tree) {
	  tree.emptyNodeAsLeaf = false;
	  tree.activeEmptyJudger = false;
	  tree.topNodeActive = true;
	  tree.nodeInitializer = treeNodeInitializer;
	  tree.initialExpandDepth = 2;
      tree.hideRoot = false;
      treeObj = tree;
      tree._rootNode.active(true);
      tree.expand();
      expandNode(tree);
} 
function expandNode(parent) {
	var childNodes = parent.getChildNodes();
	for (var i = 0; i < childNodes.length; i++) {
		childNodes[i].expand();
	}
}
function treeNodeInitializer(node) {
    node.textClicked = function(){ 
    	selectNode = node;
    	parentNode=node.parent();
        var leaf = node.data().leaf;
        var parentTypes = node.data().parentTypes;  
        var args="parentTypes="+parentTypes;
        if(leaf=="1")
        {
        	var parent=parentTypes.substring(0,parentTypes.indexOf("_"));
        	args="parentTypes="+parent;
        	var child = parentTypes.substring(parentTypes.indexOf("_")+1);
        	args+="&childTypes="+child;
        }
        //alert(args);
        ef.get("_right_iframe").src="DispatchAction.do?efFormEname=ZMCSF1&"+args; 
    };
}
function efgrid_onAjaxSubmitSuccess(gridId, service_name,method_name, eiInfo){
    var grid = efgrid.getGridObject(gridId);
    grid.refresh(eiInfo);
    if(isAddedRefresh&&selectNode){
        if(selectNode.leaf){
            if(selectNode._parent){
                selectNode._parent.reload();
            }else{
                treeObj._rootNode.reload();
            }
        }else{
            selectNode.reload();
        }
        isAddedRefresh = false;
    }
}